package com.sunrise.generico.entidade;

import java.util.Collection;
import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import lombok.Getter;
import lombok.Setter;

import com.sunrise.generico.entidade.iface.EntidadeManter;

@Entity
@Table(name = "comissao")
public class Comissao implements EntidadeManter {

	/**
	 * 
	 */
	private static final long serialVersionUID = 9015435210772191277L;

	@Id
	@SequenceGenerator(name="pk_sequence",sequenceName="comissao_id_seq", allocationSize=1)
	@GeneratedValue(strategy=GenerationType.SEQUENCE,generator="pk_sequence")
	@javax.persistence.Column
	@Getter @Setter
	private Long id;
	
	@Column(name = "nome", length = 60)
	@Getter @Setter
	private String nome;
	
	@Column(name = "dataCriacao")
	@Getter @Setter
	private Date dataCriacao;
	
	@Column(name = "dataInicio")
	@Getter @Setter
	private Date dataInicio;
	
	@Column(name = "dataFim")
	@Getter @Setter
	private Date dataFim;
	
	@OneToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, orphanRemoval = true)
	@JoinColumn(name = "comissao_id")
	@Getter @Setter
	private Collection<RegraComissao> regras;
	
	@OneToOne
	@Getter @Setter
	private Usuario criador;
	
	@OneToOne
	@Getter @Setter
	private Filial filial;
	
	@Column(name = "ativo")
	@Getter @Setter
	private Boolean ativo;
	
}
